package com.example.big_orange2.controller.WxQrCode;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.big_orange2.authorization.annotation.AuthIgnore;
import com.example.big_orange2.common.Results;
import com.example.big_orange2.entity.Staff;
import com.example.big_orange2.mapper.StaffMapper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author L.J.L
 * @QQ 963314043
 * @date 2022/8/4 14:43
 */

@RestController
@RequestMapping("loginjudge")
public class WxLoginController {

    @Resource
    StaffMapper staffMapper;
    @AuthIgnore
    @GetMapping("/op")
    public Results judge_(String openId){
        Staff staff =vueJudge(openId);

    if (staff != null){
        System.out.println(staff);
        return Results.ok().data("staff",staff);
    }
        Staff staff1 = new Staff();
        staff1.setStaffid(0);
        return Results.ok().data("staff",staff1);
    }
    private Staff vueJudge(String openId){
        QueryWrapper<Staff> wrapper = new QueryWrapper();
        wrapper.eq("openidw",openId);
        Staff staff = staffMapper.selectOne(wrapper);
        if(staff!=null){
            return staff;
        }else {
            return null;
        }
    }

}
